<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>React 实例</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
<div id="example"></div>

<script type="text/babel">
class Content extends React.Component {
  /**渲染**/
  render() {
	var value=	this.props.myDataProp;
	var value1="as"+value;
    return  <div>
			{/*onChange 变更后执行JavaScript方法,方法为传入的props中的方法指针*/}
            <input type="text" value={value} onChange={this.props.updateStateProp} /> 
            <h4>{value1}</h4>
            </div>;
  }
}
class HelloMessage extends React.Component {
	/**构造器**/
  constructor(props) {
      super(props);
	  
      this.state = {value: 'Hello Runoob!'};
      this.handleChange = this.handleChange.bind(this);
  }
 
  handleChange(event) {
    this.setState({value: event.target.value});
  }
  /**渲染**/
  render() {
    var value = this.state.value;
    return <div>
            <Content myDataProp = {value} 
              updateStateProp = {this.handleChange}></Content>
           </div>;
  }
}
ReactDOM.render(
  <HelloMessage />,
  document.getElementById('example')
);
</script>

</body>
</html>